package com.boarsoft.boar.oss.service;

import com.boarsoft.bean.ReplyInfo;

import java.io.InputStream;

public interface BoarOssClient {


    /**
     * 下载， 下载文件至本地 localFolder 目录下<br>
     *
     * @param tenantNo     租户号
     * @param fileName     文件名称， 如 aaa.txt
     * @param localFolder  本地目录 如 D:\\OSS-TEST
     * @param remoteFolder 服务目录 如 a/b/c/d
     * @return ReplyInfo.SUCCESS
     * eg: 下载远程目录 "a/b/c/d" 下的文件 "aaa.txt" 到本地目录 "D:\\OSS-TEST" 下。<br>
     *  ReplyInfo<Object> replyInfo = boarOssClient.downloadFile("001", "aaa.txt", "D:\\OSS-TEST", "a/b/c/d");
     */
    ReplyInfo<Object> downloadFile(String tenantNo, String fileName, String localFolder, String remoteFolder);

    /**
     * 流式下载，返回一个输入流<br>
     *
     * @param tenantNo   租户号
     * @param objectName objectKey + "/" + fileName<br>
     *                   例如，您对象的访问地址为examplebucket.obs.cn-north-4.myhuaweicloud.com/folder/test.txt 中，
     *                   对象名为folder/test.txt。
     * @return InputStream <br>
     * eg:  InputStream inputStream = boarOssClient.download("001", "13/1397/aaa.txt");
     */
    public InputStream download(String tenantNo, String objectName);

    /**
     * 流式上传<br>
     *
     * @param tenantNo     租户号
     * @param inputStream  文件流
     * @param fileName     文件名称 如 aaa.txt
     * @param remoteFolder 服务目录 如 a/b/c/d
     * @return ReplyInfo.SUCCESS
     * eg: <br>
     * inputStream = new FileInputStream("D:\\OSS-TEST\\aaa.txt");<br>
     * ReplyInfo<Object> replyInfo = boarOssClient.uploadFile("001", inputStream, "aaa.txt", "a/b/c/d");<br>
     */
    ReplyInfo<Object> uploadFile(String tenantNo, InputStream inputStream, String fileName, String remoteFolder);

    /**
     * 上传文件<br>
     *
     * @param tenantNo     租户号
     * @param fileName     文件名 如 aaa.txt
     * @param localFolder  本地目录 如 D:\\DOCS\\OSS
     * @param remoteFolder 服务目录 如 01/20240322/aa
     * @return ReplyInfo.SUCCESS<br>
     * eg: ReplyInfo<Object> replyInfo = boarOssClient.uploadFile("001", "aaa.txt", "D:\\DOCS\\OSS", "01/20240322/aa");<br>
     */
    ReplyInfo<Object> uploadFile(String tenantNo, String fileName, String localFolder, String remoteFolder);

    /**
     * 删除<br>
     *
     * @param tenantNo     租户号
     * @param key          对象全路径名
     * @return ReplyInfo.SUCCESS
     * eg: ReplyInfo<Object>  replyInfo = boarOssClient.deleteFile("001", "a/b/c/d/aaa.txt");<br>
     */
    ReplyInfo<Object> deleteFile(String tenantNo, String key);

    /**
     * 列出 bucketName 下的所有文件，各oss实现会有数量限制，如 aliyun oss 分页为100 <br>
     *
     * @param tenantNo     租户号
     * @param bucketName   桶名称
     * @return ReplyInfo.getData() => List<String> <br>
     */
    ReplyInfo<Object> list(String tenantNo, String bucketName);

}
